#include "stdafx.h"
#include "ParserErrorService.h"
#include "CCoreServices.h"

ParserErrorService::ParserErrorService()
{

	this->m_pCore = NULL;

}

ParserErrorService::~ParserErrorService()
{

	NOTIMPL

}

void ParserErrorService::Initialize(CCoreServices * pCore)
{

	this->m_pCore = pCore;

}

HRESULT ParserErrorService::ReportError(XUINT32 iErrorCode, XUINT32 uLine, XUINT32 uColumn, XUINT32 uParamCount, XBOOL bRecoverable, xshared_ptr<CXString> & spMessage)
{

	CXString * pstrMessage;
	IErrorService *pErrorService; 
	unsigned int i; 
	int hr; 
	hr = 0;
	pErrorService = 0;
	pstrMessage = NULL;

	if (true )
	{
		if ( uParamCount > MAX_ERROR_PARAMS )
		{
			//
		}
		if ( uParamCount <= MAX_ERROR_PARAMS )
		{
			hr = m_pCore->getErrorService(&pErrorService);
			if ( SUCCEEDED(hr) )
			{
				if ( pErrorService )
				{
					if ( &spMessage)
					{
						*pstrMessage = *spMessage;
					}

					hr = pErrorService->ReportParserError(iErrorCode, bRecoverable, NULL, NULL, NULL, uLine, uColumn, pstrMessage, (XSTRING **)&m_ErrorParams, uParamCount);

					if ( hr >= 0 )
					{
						this->m_bErrorRecorded = TRUE;
					}
				}
			}
		}
		else
		{
			hr = 0x8000FFFFu;
		}
	}
	for ( i = 0; i < 2; ++i )
	{
		delete &this->m_ErrorParams[i];
		this->m_ErrorParams[i]->cString = 0;
	}
	return hr;

}
